package com.gipson.amc.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gipson.amc.model.Menu;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 用户
 * </p>
 *
 * @author zj
 * @since 2020-04-26
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("SYS_USER")
public class User extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 用户名
     */
    @TableField("USERNAME")
    private String username;

    /**
     * 密码
     */
    @TableField("PASSWORD")
    private String password;

    /**
     * 姓名
     */
    @TableField("NAME")
    private String name;

    /**
     * 工号
     */
    @TableField("USER_CODE")
    private String userCode;

    /**
     * 公司编码
     */
    @TableField("COMPANY_CODE")
    private String companyCode;

    /**
     * 加密混淆码
     */
    @TableField("SALT")
    private String salt;

    /**
     * 是否默认系统管理员   2：系统管理员
     */
    @TableField("SYS_FLAG")
    private int sysFlag;

    @TableField(exist = false)
    private List<Menu> menus;

    //自定义
    @TableField(exist = false)
    private String companyName;

    @TableField(exist = false)
    private List<Role> roles;

    @TableField(exist = false)
    private List<Authority> authorities;

    @TableField(exist = false)
    private List<String> roleCodes;

    @TableField(exist = false)
    private List<String> authorityCodes;

    @TableField(exist = false)
    private String newPassWord;

    /**
     * 获取用户身份。
     * @param
     * @return
     * @author cjw 2020-05-23
     */
    public String getUserIdentity(){
        return this.userCode+"-"+this.name;
    }

    @TableField(exist = false)
    private String passwordShown;
}
